import flash.events.Event;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.geom.Matrix;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.text.TextField;
import flash.text.TextFormat;

import Images;
import CutScene;
import CustomSprite;
import TimelineContainer;
import Constants;

class KongLogo extends TimelineContainer {
public var backgroundTimeline:Timeline;
public var textTimeline:Timeline;
public var TotalFrames:Int;
public var sheet:KongLoaderSheet;
  private var LogoBitmapData:BitmapData;
  private var LogoBitmap:Bitmap;
  public function new()
  {
  LogoBitmapData = new BitmapData(2048, 
          2048, true, 0);
  LogoBitmap = new Bitmap(LogoBitmapData);
  sheet = new KongLoaderSheet();
  TotalFrames = 90;
  backgroundTimeline = new Timeline(0,TotalFrames,1);
  textTimeline = new Timeline(25,190,2);

  var inBackground:BitmapData = new Background();
  backgroundTimeline.graphics.beginFill(0x000000,1);
  backgroundTimeline.graphics.drawRect(0, 0, inBackground.width,inBackground.height);
  backgroundTimeline.x = 0; backgroundTimeline.y = 0;

LogoBitmap.x = 256;
LogoBitmap.y = 149;
  backgroundTimeline.addChild(LogoBitmap);
    super(backgroundTimeline,TotalFrames);
  
   // add(textTimeline);
    start();

  }
      public override function actions()
      { 
	LogoBitmapData.fillRect(LogoBitmapData.rect, 0);
	var sourceRectangle:Rectangle = new Rectangle
	      (
		Std.int((frame*2.2222222)%16) * 128, 
		Std.int((frame*2.2222222)/16)* 128, 
		128, 
		128
	      );
	var destinationPoint:Point = new Point
	(
	  0,0
	);
	LogoBitmapData.copyPixels
	(
	sheet, 
	sourceRectangle, 
	destinationPoint,
	null, null, true
	);
      }
 }

